package com.test.wog.util;

import org.springframework.stereotype.Component;

/**
 * 去除geom字段的前置POINT等
 *
 * @author linxun@buaa.edu.cn
 * @since 2020-01-27
 */
@Component
public class GeometryTrimUtil {
    /**
     * Trim point string.
     *
     * @param geom the geom
     * @return the string
     */
    public String trimPoint(String geom){//去除st_astext后，geom中的point(x,x)
        String geomTrimLeft =  "trim(leading 'POINT(' from " + geom + ")";
        String geomTrimRight = "trim(trailing ')' from " + geomTrimLeft + ")";
        return geomTrimRight;
    }

    /**
     * Trim line string.
     *
     * @param geom the geom
     * @return the string
     */
    public String trimLine(String geom){//去除st_astext后，geom中的linestring(x,x)
        String geomTrimLeft =  "trim(leading 'LINESTRING(' from " + geom + ")";
        String geomTrimRight = "trim(trailing ')' from " + geomTrimLeft + ")";
        return geomTrimRight;
    }
}
